<template>
    <div class="dialog">
        <div class="dialog-cont">
            <div class="dialog-cont-title">{{ title }}</div>
            <div class="dialog-cont-body">{{ content }}</div>
            <div class="dialog-cont-footer">
                <button class="cancel" v-if="isCancel" @click="cancel">取消</button>
                <button class="confirm" @click="confirm">确定</button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        title: {
            type: String,
            default: "标题",
        },
        content: {
            type: String,
            default: "内容",
        },
        isCancel: {
            type: Boolean,
            default: true,
        },
    },
    methods:{
        cancel(){
            this.$emit("onCancel");  
        },
        confirm(){
            this.$emit("onConfirm");  
        },
    }
};
</script>

<style lang="scss">
.dialog {
    position: fixed;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.6);
    width: 100vw;
    height: 100vh;
    @include center;

    &-cont {
        background-color: white;
        box-shadow: 0 2.8px 2.2px rgba(0, 0, 0, 0.2);
        width: 80%;
        max-width: 400px;
        margin: 0 auto;
        border-radius: 10px;
        text-align: center;

        &-title {
            font-size: 18px;
            padding: 15px;
        }

        &-body {
            color: $font-color;
            font-size: 16px;
            padding: 15px;
        }

        &-footer {
            font-size: 16px;
            padding: 15px;
            display: flex;

            > button + button {
                margin-left: 8px;
            }

            > button {
                flex: 1;
                border: none;
                border-radius: 10px;
                font-size: 18px;
                padding: 8px;

                &.confirm {
                    background-color: $main-color;
                    color: white;
                }
            }
        }
    }
}
</style>